<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script>
			// function Person(firstName, lastName, age) {
			//     this.firstName = firstName;
			//     this.lastName = lastName;
			//     this.age = age;
			//     this.greet = function() {
			//         console.log("Hello, " + this.firstName + " " + this.lastName+", "+ this.age);
			//     };
			// }
			// let person = new Person("John", "Doe", 30);
			// person.greet();
			// let personPrototype = {
			//     greet: function() {
			//         console.log("Hello, " + this.firstName + " " + this.lastName);
			//     }
			// };
			// let person = Object.create(personPrototype);
			// person.firstName = "John";
			// person.lastName = "Doe";
			// person.age = 30;
			// person.greet();
			
			// class Person {
			//     constructor(firstName, lastName, age) {
			//         this.firstName = firstName;
			//         this.lastName = lastName;
			//         this.age = age;
			//     }
			//     greet() {
			//         console.log("Hello, " + this.firstName + " " + this.lastName);
			//     }
			// }
			// let person = new Person("John", "Doe", 30);
			// person.greet();
			
			//字面量创建对象
			var ldh = {
			    name: '刘德华',
			    age: 18
			}
			console.log(ldh);
			//构造函数创建对象
			  function Star(name, age) {
			    this.name = name;
			    this.age = age;
			 }
			var ldh = new Star('刘德华', 18)//实例化对象
			console.log(ldh);	
			
		</script>
	</body>
</html>